<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>权限管理</el-breadcrumb-item>
    <el-breadcrumb-item>权限列表</el-breadcrumb-item>
  </el-breadcrumb>

  <el-card>
    <!-- 表格区域 -->
    <el-table stripe size="large" :data="rights" border style="width: 100%">
      <el-table-column label="#" type="index" width="50" />
      <el-table-column prop="authName" label="权限名称" />
      <el-table-column prop="path" label="路径" />
      <el-table-column prop="roleDesc" label="权限等级">
        <template #default="scope">
          <el-tag v-if="scope.row.level === '0'">一级</el-tag>
          <el-tag type="success" v-if="scope.row.level === '1'">二级</el-tag>
          <el-tag type="warning" v-if="scope.row.level === '2'">三级</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script setup lang="ts">
import { ref, onMounted, getCurrentInstance } from 'vue';
import { getRightsListApi } from '@/api/authInterface'

onMounted(() => {
  getRightsList()
})

const rights = ref()
const getRightsList = () => {
  getRightsListApi('list').then(res => {
    rights.value = res.data
  })
}
</script>

<style scoped lang="scss">
.el-card {
  margin-top: 20px;
}

.el-table {
  margin-top: 20px;
}
</style>